from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
import numpy

# 定义需要编译为pyd的扩展模块
extensions = [
    Extension(
        "app.services.dicom_service_optimized",
        ["app/services/dicom_service_optimized.py"],
        include_dirs=[numpy.get_include()],
        define_macros=[("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")],
    ),
    Extension(
        "app.services.file_service",
        ["app/services/file_service.py"],
    ),
    Extension(
        "app.utils.config",
        ["app/utils/config.py"],
    ),
]

setup(
    name="dicom_server",
    version="1.0.0",
    description="DICOM Server with optimized services",
    packages=find_packages(),
    ext_modules=cythonize(
        extensions,
        compiler_directives={
            'language_level': 3,
            'boundscheck': False,  # 关闭边界检查以提高性能
            'wraparound': False,   # 关闭负索引回绕检查
            'nonecheck': False,    # 关闭None检查
        }
    ),
    install_requires=[
        "fastapi",
        "uvicorn",
        "pydicom",
        "python-multipart",
        "python-dotenv",
        "numpy",
        "pillow",
    ],
    python_requires=">=3.8",
)